﻿package {
	import flash.display.Sprite;
	import flash.text.*;
	import flash.utils.*;
	import flash.events.*;

	public class Main extends Sprite {
		
		private var myText:String = "Type your text here."; 
		private var intputField:TextField = new TextField();
		private var outputField:TextField = new TextField();
		private var a:Array=new Array  ;
		private var b:Array=new Array  ;
		public var i:Number=0;
		


		public function Main():void {

			intputField.text = myText;
			outputField.text = "顯示輸出文字";
			intputField.type = TextFieldType.INPUT; 			
			intputField.border = true;
			outputField.wordWrap = true;
			outputField.border = true;
			intputField.height = 30;
			outputField.height = 100;
			intputField.width = 250;
			outputField.width = 250;
			
			intputField.x = 150;
			intputField.y = 50;
			outputField.x = 150;
			outputField.y = 150;
			addChild(intputField);
			addChild(outputField);
			

			addEventListener(KeyboardEvent.KEY_DOWN,inputArray);
		}
		public function inputArray(event:KeyboardEvent):void {
			
			 
			var Filter:RegExp=/(中國共產黨)|(馬英九)|(陳水扁)/g;
			
			if (event.keyCode==13) {
				i++;
				trace(i);
				a[i]=intputField.text;
				b[i]=a[i].replace(Filter,"*");

				outputField.text=String(b);
				intputField.text="";
				trace(b)
			}

		}

	}
}